#coding:utf-8
from common.requestUtils import requestUtils
import time,json
from common.comm import getDomain,getCofing
import requests,enum

user = getCofing('user')

hd_user= user['hd_username']
print(hd_user)
hd_password = user['hd_password']

op_user = user['op_username']
op_password = user['op_password']

def huidian_token():
    url = getDomain('auth_url')+'/access/login'
    #print(url)
    param = {'av':1,'account':hd_user,'pwd':hd_password,'platform':'web'}
    #print(param)
    respones = requests.get(url,param)
    print(respones.text)
    re=json.loads(respones.text)
    if re['code'] == 0:
        l=re["data"]
        #print("l")
        #print("token = ",re["data"]["token"])
        return re['data']['token']#re['data']['b_auto_id'],re['data']['user_id']


def op_token():
    url = getDomain('op_url')+'/login/get_token'
    now_time = time.time()
    param = {'username':op_user,'pwd':op_password,'time':now_time}
    response = requestUtils().get(url,params=param)
    if response['code']==0:
        return response['data']['token']
        #print(response["data"]["token"])

h_token = huidian_token()

if __name__ == '__main__':
    huidian_token()

